import os, time, datetime 


def listFiles(basedir, exclude):
    for root, dirs, files in os.walk(basedir, topdown=False):

            for name in files:
                p = os.path.join(root, name)
                d =  datetime.datetime.fromtimestamp( os.path.getmtime( p ) )
                diff = datetime.datetime.today() - d 
                if diff.days > 30:
                    print "file ", p,   " > 30 days =", diff.days

                if( p not in exclude and diff.days > 30   ):
                    print p ,"-> ", d
                    #os.remove(p)
                    
                else:
                    print "Excluding ", os.path.join(root, name)
        
            for name in dirs:
                p = os.path.join(root, name)
                d =  datetime.datetime.fromtimestamp( os.path.getmtime( p ) )
                diff = datetime.datetime.today() - d 
                if diff.days > 30:
                    print "file ", p,   " > 30 days =", diff.days
                    
                if(  p not in exclude and diff.days > 30  ):
                    print p ,"-> ", d
                    #os.rmdir( p )
                else:
                    print "Excluding ", p
        
